home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / CAT70103.SQL < prev    next >
Encoding:
Text File  |  1995-05-09  |  49.8 KB  |  1,484 lines

  1. rem 
  2. rem $Header: cat70103.sql 7020100.1 94/09/23 22:14:06 cli Generic<base> $ 
  3. rem 
  4. Rem  Copyright (c) 1992 by Oracle Corporation 
  5. Rem    NAME
  6. Rem      cat70103.sql - upgrade Oracle RDBMS from version 7.1.2 to 7.1.3
  7. Rem    DESCRIPTION
  8. Rem 
  9. Rem    NOTES
  10. Rem      Run this as INTERNAL.  Run it before installing catalog or pl/sql.
  11. Rem      It is safe to run it on 7.1.2.
  12. Rem    MODIFIED   (MM/DD/YY)
  13. Rem     vraghuna   04/08/94 -  merge forward expact and expver changes
  14. Rem     jcohen     04/07/94 -  merge changes from branch 1.1.710.3
  15. Rem     jcohen     04/07/94 -  merge changes from branch 1.1.710.2
  16. Rem     agupta     03/28/94 -  merge changes from branch 1.1.710.5
  17. Rem     thayes     03/22/94 -  merge changes from branch 1.1.710.14
  18. Rem     rjenkins   03/09/94 -  merge changes from branch 1.1.710.8
  19. Rem     rjenkins   03/09/94 -  merge changes from branch 1.1.710.7
  20. Rem     rjenkins   03/09/94 -  merge changes from branch 1.1.710.4
  21. Rem     rjenkins   01/19/94 -  merge changes from branch 1.1.710.1
  22. Rem     thayes     03/03/94 -  New syns for compat seg
  23. Rem     ltung      02/24/94 -  replace _TABLES and _CLUSTERS views
  24. Rem     ltung      02/24/94 -  preserve CACHEing in tab$, clu$
  25. Rem     cozbutun   02/10/94 -  fix the last change
  26. Rem     vraghuna   02/10/94 -  add new row into props
  27. Rem     cozbutun   02/10/94 -  change the index i_triggercol1
  28. Rem     vraghuna   02/07/94 -  add expver for versioning support
  29. Rem     rjenkins   02/07/94 -  adding unique index on rgroup
  30. Rem     rjenkins   02/02/94 -  replace M IDEN with 30
  31. Rem     vraghuna   01/31/94 -  bug 191751 - add expact
  32. Rem     agupta     01/20/94 -  192948 - make *_extent in *_segments byte-based
  33. Rem     rjenkins   01/13/94 -  adding rollback seg col to rgroup$
  34. Rem     jcohen     01/04/94 - #(192450) add v$option table
  35. Rem     jcohen     12/20/93 - #(191673) fix number fmt for user_tables,cluster
  36. Rem     rjenkins   12/20/93 -  Branch_for_patch
  37. Rem     rjenkins   12/17/93 -  Creation
  38.  
  39. rem 
  40. rem  Job Queue
  41. rem
  42. drop table job$ cascade constraints
  43. /
  44. drop sequence jobseq
  45. /
  46. create sequence jobseq
  47.   start with 1
  48.   increment by 1
  49.   minvalue 1
  50.   maxvalue 999999999                        /* should be less than MAXSB4VAL */
  51.   cache 20
  52.   noorder
  53.   cycle
  54. /
  55. create table job$
  56. ( job             number not null,                  /* identifier of the job */
  57.   lowner          varchar2(30) not null,             /* logged in user */
  58.   powner          varchar2(30) not null,                   /* security */
  59.   cowner          varchar2(30) not null,                    /* parsing */
  60.   last_date       date,                      /* when this job last succeeded */
  61.   this_date       date,    /* when the current execute started, usually null */
  62.   next_date       date not null,             /* when to execute the job next */
  63.   total           number default 0 not null, /* total time spent on this job */
  64.   interval        varchar2(200) not null,/* function for next next_date */
  65.   failures        number,           /* number of failures since last success */
  66.   flag            number default 0 not null,     /* 0x01, this job is broken */
  67.   what            varchar2(2000),        /* PL/SQL text, what is the job */
  68.   nlsenv          varchar2(2000),                      /* nls parameters */
  69.   env             raw(32),                    /* other environment variables */
  70.   cur_ses_label   mlslabel,      /* current session label for trusted oracle */
  71.   clearance_hi    mlslabel,             /* clearance high for trusted oracle */
  72.   clearance_lo    mlslabel,              /* clearance low for trusted oracle */
  73.   charenv         varchar2(2000),                            /* not used */
  74.   field1          number default 0)                              /* not used */
  75. /
  76. create unique index i_job_job on job$ (job)
  77. /
  78. create index i_job_next on job$ (next_date)
  79. /
  80. rem
  81. rem  Refresh Groups
  82. rem
  83. drop table rgchild$ cascade constraints
  84. /
  85. drop table rgroup$ cascade constraints
  86. /
  87. drop cluster c_rg# including tables cascade constraints
  88. /
  89. drop sequence rgroupseq
  90. /
  91. create sequence rgroupseq
  92.   start with 1
  93.   increment by 1
  94.   minvalue 1
  95.   maxvalue 999999999                        /* should be less than MAXSB4VAL */
  96.   cache 20
  97.   noorder
  98.   cycle
  99. /
  100. create cluster c_rg#
  101. ( refgroup        number)                            /* refresh group number */
  102. /
  103. create index i_rg# on cluster c_rg#
  104. /
  105. create table rgroup$
  106. ( refgroup        number,                         /* number of refresh group */
  107.   owner           varchar2(30) not null,     /* owner of refresh group */
  108.   name            varchar2(30) not null,      /* name of refresh group */
  109.   flag            number default 0,        /* 0x01, destroy group when empty */
  110.                                                  /* 0x02, do not push queues */
  111.                                                /* 0x04, refresh after errors */
  112.   rollback_seg    varchar2(30),                   /* rollback segment to use */
  113.   field1          number default 0,
  114.   job             number not null)  /* job in job$ for refreshing this group */
  115. cluster c_rg# (refgroup)
  116. /
  117. create unique index i_rgroup on rgroup$ (owner, name)
  118. /
  119. create unique index i_rgref on rgroup$ (refgroup)
  120. /
  121. create index i_rgjob on rgroup$ (job)
  122. /
  123. create table rgchild$
  124. ( owner           varchar2(30) not null,             /* owner of child */
  125.   name            varchar2(30) not null,              /* name of child */
  126.   type            varchar2(30) default 'SNAPSHOT',   /* type of object */
  127.   field1          number default 0,
  128.   refgroup        number)                   /* refresh group the child is in */
  129. cluster c_rg# (refgroup)
  130. /
  131. create unique index i_rgchild on rgchild$ (owner, name, type)
  132. /
  133. rem
  134. rem  Drop User Cascade
  135. rem
  136. drop table duc$ cascade constraints
  137. /
  138. create table duc$
  139. ( owner           varchar2(30) not null,            /* procedure owner */
  140.   pack            varchar2(30) not null,          /* procedure package */
  141.   proc            varchar2(30) not null,             /* procedure name */
  142.   field1          number default 0,
  143.   operation       number not null,                    /* 1=drop user cascade */
  144.   seq             number not null,            /* for ordering the procedures */
  145.   com             varchar2(80))       /* comment on what this routine is for */
  146. /
  147. create unique index i_duc on duc$ (owner,pack,proc,operation)
  148. /
  149. rem
  150. rem  Create refresh groups & jobs for all existing snapshots
  151. rem
  152. insert into rgroup$ (refgroup, owner, name, flag, job)
  153.   select rownum, sowner, vname, 1, rownum from snap$
  154.   where auto_date is not null or auto_fun is not null
  155. /
  156. insert into rgchild$ (owner, name, refgroup)
  157.   select owner, name, refgroup from rgroup$
  158. /
  159. insert into job$ (job, lowner, powner, cowner, 
  160.                   next_date, 
  161.                   interval, 
  162.                   what, 
  163.                   nlsenv, env)
  164.   select r.refgroup, r.owner, r.owner, r.owner,
  165.          nvl(s.auto_date,to_date('4000-01-01','YYYY-MM-DD')),
  166.          nvl(s.auto_fun,'null'),
  167.          'dbms_refresh.refresh(''"'||r.owner||'"."'||r.name||'"'');',
  168.          'SQL_TRACE=FALSE', hextoraw('0102000000000000')
  169.     from snap$ s, rgroup$ r 
  170.     where r.owner = s.sowner and r.name = s.vname;
  171. /
  172.  
  173. rem
  174. rem  maintain CACHE attribute for tables and clusters
  175. rem
  176. update tab$ set spare2 = 65536 where spare2 > 0
  177. /
  178. update clu$ set spare6 = 65536 where spare6 > 0
  179. /
  180. remark
  181. remark  FAMILY "CLUSTERS"
  182. remark  CREATE CLUSTER parameters.
  183. remark  This family has no "ALL" member.
  184. remark
  185. create or replace view USER_CLUSTERS
  186.     (CLUSTER_NAME, TABLESPACE_NAME,
  187.      PCT_FREE, PCT_USED, KEY_SIZE,
  188.      INI_TRANS, MAX_TRANS,
  189.      INITIAL_EXTENT, NEXT_EXTENT,
  190.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  191.      AVG_BLOCKS_PER_KEY,
  192.      CLUSTER_TYPE, FUNCTION, HASHKEYS,
  193.      DEGREE, INSTANCES, CACHE)
  194. as select o.name, ts.name,
  195.           c.pctfree$, c.pctused$, c.size$,c.initrans,c.maxtrans,
  196.           s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  197.           s.minexts, s.maxexts, s.extpct,
  198.           c.spare4, decode(c.hashkeys, 0, 'INDEX', 'HASH'),
  199.           decode(c.hashkeys, 0, NULL,
  200.                  decode(c.func, 0, 'COLUMN', 1, 'DEFAULT', NULL)),
  201.           c.hashkeys,
  202.           lpad(decode(c.spare5, 0, '1', 1, 'DEFAULT', to_char(c.spare5)), 10),
  203.           lpad(decode(mod(c.spare6, 65536), 0, '1', 1, 'DEFAULT',
  204.           to_char(mod(c.spare6, 65536))), 10),
  205.           lpad(decode(floor(c.spare6 / 65536), 0, 'N', 1, 'Y', '?'), 5)
  206. from sys.ts$ ts, sys.seg$ s, sys.clu$ c, sys.obj$ o
  207. where o.owner# = userenv('SCHEMAID')
  208.   and o.obj# = c.obj#
  209.   and c.ts# = ts.ts# 
  210.   and c.ts# = s.ts#
  211.   and c.file# = s.file#
  212.   and c.block# = s.block#
  213. /
  214. comment on table USER_CLUSTERS is
  215. 'Descriptions of user''s own clusters'
  216. /
  217. comment on column USER_CLUSTERS.CLUSTER_NAME is
  218. 'Name of the cluster'
  219. /
  220. comment on column USER_CLUSTERS.TABLESPACE_NAME is
  221. 'Name of the tablespace containing the cluster'
  222. /
  223. comment on column USER_CLUSTERS.PCT_FREE is
  224. 'Minimum percentage of free space in a block'
  225. /
  226. comment on column USER_CLUSTERS.PCT_USED is
  227. 'Minimum percentage of used space in a block'
  228. /
  229. comment on column USER_CLUSTERS.KEY_SIZE is
  230. 'Estimated size of cluster key plus associated rows'
  231. /
  232. comment on column USER_CLUSTERS.INI_TRANS is
  233. 'Initial number of transactions'
  234. /
  235. comment on column USER_CLUSTERS.MAX_TRANS is
  236. 'Maximum number of transactions'
  237. /
  238. comment on column USER_CLUSTERS.INITIAL_EXTENT is
  239. 'Size of the initial extent in bytes'
  240. /
  241. comment on column USER_CLUSTERS.NEXT_EXTENT is
  242. 'Size of secondary extents in bytes'
  243. /
  244. comment on column USER_CLUSTERS.MIN_EXTENTS is
  245. 'Minimum number of extents allowed in the segment'
  246. /
  247. comment on column USER_CLUSTERS.MAX_EXTENTS is
  248. 'Maximum number of extents allowed in the segment'
  249. /
  250. comment on column USER_CLUSTERS.PCT_INCREASE is
  251. 'Percentage increase in extent size'
  252. /
  253. comment on column USER_CLUSTERS.AVG_BLOCKS_PER_KEY is
  254. 'Average number of blocks containing rows with a given cluster key'
  255. /
  256. comment on column USER_CLUSTERS.CLUSTER_TYPE is
  257. 'Type of cluster: b-tree index or hash'
  258. /
  259. comment on column USER_CLUSTERS.FUNCTION is
  260. 'If a hash cluster, the hash function'
  261. /
  262. comment on column USER_CLUSTERS.HASHKEYS is
  263. 'If a hash cluster, the number of hash keys (hash buckets)'
  264. /
  265. comment on column USER_CLUSTERS.DEGREE is
  266. 'The number of threads per instance for scanning the cluster'
  267. /
  268. comment on column USER_CLUSTERS.INSTANCES is
  269. 'The number of instances across which the cluster is to be scanned'
  270. /
  271. comment on column USER_CLUSTERS.CACHE is
  272. 'Whether the cluster is to be cached in the buffer cache'
  273. /
  274. drop public synonym USER_CLUSTERS
  275. /
  276. create public synonym USER_CLUSTERS for USER_CLUSTERS
  277. /
  278. drop public synonym CLU
  279. /
  280. create public synonym CLU for USER_CLUSTERS
  281. /
  282. grant select on USER_CLUSTERS to PUBLIC with grant option
  283. /
  284. create or replace view DBA_CLUSTERS
  285.     (OWNER, CLUSTER_NAME, TABLESPACE_NAME,
  286.      PCT_FREE, PCT_USED, KEY_SIZE,
  287.      INI_TRANS, MAX_TRANS,
  288.      INITIAL_EXTENT, NEXT_EXTENT,
  289.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  290.      AVG_BLOCKS_PER_KEY,
  291.      CLUSTER_TYPE, FUNCTION, HASHKEYS,
  292.      DEGREE, INSTANCES, CACHE)
  293. as select u.name, o.name, ts.name,
  294.           c.pctfree$, c.pctused$, c.size$,c.initrans,c.maxtrans,
  295.           s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  296.           s.minexts, s.maxexts, s.extpct,
  297.           c.spare4, decode(c.hashkeys, 0, 'INDEX', 'HASH'),
  298.           decode(c.hashkeys, 0, NULL,
  299.                  decode(c.func, 0, 'COLUMN', 1, 'DEFAULT', NULL)),
  300.           c.hashkeys,
  301.           lpad(decode(c.spare5, 0, '1', 1, 'DEFAULT', to_char(c.spare5)), 10),
  302.           lpad(decode(mod(c.spare6, 65536), 0, '1', 1, 'DEFAULT',
  303.           to_char(mod(c.spare6, 65536))), 10),
  304.           lpad(decode(floor(c.spare6 / 65536), 0, 'N', 1, 'Y', '?'), 5)
  305. from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.clu$ c, sys.obj$ o
  306. where o.owner# = u.user#
  307.   and o.obj# = c.obj#
  308.   and c.ts# = ts.ts#
  309.   and c.ts# = s.ts#
  310.   and c.file# = s.file#
  311.   and c.block# = s.block#
  312. /
  313. comment on table DBA_CLUSTERS is
  314. 'Description of all clusters in the database'
  315. /
  316. comment on column DBA_CLUSTERS.OWNER is
  317. 'Owner of the cluster'
  318. /
  319. comment on column DBA_CLUSTERS.CLUSTER_NAME is
  320. 'Name of the cluster'
  321. /
  322. comment on column DBA_CLUSTERS.TABLESPACE_NAME is
  323. 'Name of the tablespace containing the cluster'
  324. /
  325. comment on column DBA_CLUSTERS.PCT_FREE is
  326. 'Minimum percentage of free space in a block'
  327. /
  328. comment on column DBA_CLUSTERS.PCT_USED is
  329. 'Minimum percentage of used space in a block'
  330. /
  331. comment on column DBA_CLUSTERS.KEY_SIZE is
  332. 'Estimated size of cluster key plus associated rows'
  333. /
  334. comment on column DBA_CLUSTERS.INI_TRANS is
  335. 'Initial number of transactions'
  336. /
  337. comment on column DBA_CLUSTERS.MAX_TRANS is
  338. 'Maximum number of transactions'
  339. /
  340. comment on column DBA_CLUSTERS.INITIAL_EXTENT is
  341. 'Size of the initial extent in bytes'
  342. /
  343. comment on column DBA_CLUSTERS.NEXT_EXTENT is
  344. 'Size of secondary extents in bytes'
  345. /
  346. comment on column DBA_CLUSTERS.MIN_EXTENTS is
  347. 'Minimum number of extents allowed in the segment'
  348. /
  349. comment on column DBA_CLUSTERS.MAX_EXTENTS is
  350. 'Maximum number of extents allowed in the segment'
  351. /
  352. comment on column DBA_CLUSTERS.PCT_INCREASE is
  353. 'Percentage increase in extent size'
  354. /
  355. comment on column DBA_CLUSTERS.AVG_BLOCKS_PER_KEY is
  356. 'Average number of blocks containing rows with a given cluster key'
  357. /
  358. comment on column DBA_CLUSTERS.CLUSTER_TYPE is
  359. 'Type of cluster: b-tree index or hash'
  360. /
  361. comment on column DBA_CLUSTERS.FUNCTION is
  362. 'If a hash cluster, the hash function'
  363. /
  364. comment on column DBA_CLUSTERS.HASHKEYS is
  365. 'If a hash cluster, the number of hash keys (hash buckets)'
  366. /
  367. comment on column DBA_CLUSTERS.DEGREE is
  368. 'The number of threads per instance for scanning the cluster'
  369. /
  370. comment on column DBA_CLUSTERS.INSTANCES is
  371. 'The number of instances across which the cluster is to be scanned'
  372. /
  373. comment on column DBA_CLUSTERS.CACHE is
  374. 'Whether the cluster is to be cached in the buffer cache'
  375. /
  376. remark
  377. remark  FAMILY "TABLES"
  378. remark  CREATE TABLE parameters.
  379. remark
  380. create or replace view USER_TABLES
  381.     (TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME,
  382.      PCT_FREE, PCT_USED,
  383.      INI_TRANS, MAX_TRANS,
  384.      INITIAL_EXTENT, NEXT_EXTENT,
  385.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  386.      BACKED_UP, NUM_ROWS, BLOCKS, EMPTY_BLOCKS,
  387.      AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN,
  388.      DEGREE, INSTANCES, CACHE)
  389. as
  390. select o.name, ts.name, co.name,
  391.        t.pctfree$, t.pctused$,
  392.        t.initrans, t.maxtrans,
  393.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  394.        s.minexts, s.maxexts, s.extpct,
  395.        decode(t.modified, 0, 'Y', 1, 'N', '?'),
  396.        t.rowcnt, t.blkcnt, t.empcnt, t.avgspc, t.chncnt, t.avgrln,
  397.        lpad(decode(t.spare1, 0, '1', 1, 'DEFAULT', to_char(t.spare1)), 10),
  398.        lpad(decode(mod(t.spare2, 65536), 0, '1', 1, 'DEFAULT',
  399.        to_char(mod(t.spare2, 65536))), 10),
  400.        lpad(decode(floor(t.spare2 / 65536), 0, 'N', 1, 'Y', '?'), 5)
  401. from sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o
  402. where o.owner# = userenv('SCHEMAID')
  403.   and o.obj# = t.obj#
  404.   and t.clu# = co.obj# (+)
  405.   and t.ts# = ts.ts#
  406.   and t.file# = s.file# (+)
  407.   and t.block# = s.block# (+)
  408. /
  409. comment on table USER_TABLES is
  410. 'Description of the user''s own tables'
  411. /
  412. comment on column USER_TABLES.TABLE_NAME is
  413. 'Name of the table'
  414. /
  415. comment on column USER_TABLES.TABLESPACE_NAME is
  416. 'Name of the tablespace containing the table'
  417. /
  418. comment on column USER_TABLES.CLUSTER_NAME is
  419. 'Name of the cluster, if any, to which the table belongs'
  420. /
  421. comment on column USER_TABLES.PCT_FREE is
  422. 'Minimum percentage of free space in a block'
  423. /
  424. comment on column USER_TABLES.PCT_USED is
  425. 'Minimum percentage of used space in a block'
  426. /
  427. comment on column USER_TABLES.INI_TRANS is
  428. 'Initial number of transactions'
  429. /
  430. comment on column USER_TABLES.MAX_TRANS is
  431. 'Maximum number of transactions'
  432. /
  433. comment on column USER_TABLES.INITIAL_EXTENT is
  434. 'Size of the initial extent in bytes'
  435. /
  436. comment on column USER_TABLES.NEXT_EXTENT is
  437. 'Size of secondary extents in bytes'
  438. /
  439. comment on column USER_TABLES.MIN_EXTENTS is
  440. 'Minimum number of extents allowed in the segment'
  441. /
  442. comment on column USER_TABLES.MAX_EXTENTS is
  443. 'Maximum number of extents allowed in the segment'
  444. /
  445. comment on column USER_TABLES.PCT_INCREASE is
  446. 'Percentage increase in extent size'
  447. /
  448. comment on column USER_TABLES.BACKED_UP is
  449. 'Has table been backed up since last modification?'
  450. /
  451. comment on column USER_TABLES.NUM_ROWS is
  452. 'The number of rows in the table'
  453. /
  454. comment on column USER_TABLES.BLOCKS is
  455. 'The number of used blocks in the table'
  456. /
  457. comment on column USER_TABLES.EMPTY_BLOCKS is
  458. 'The number of empty (never used) blocks in the table'
  459. /
  460. comment on column USER_TABLES.AVG_SPACE is
  461. 'The average available free space in the table'
  462. /
  463. comment on column USER_TABLES.CHAIN_CNT is
  464. 'The number of chained rows in the table'
  465. /
  466. comment on column USER_TABLES.AVG_ROW_LEN is
  467. 'The average row length, including row overhead'
  468. /
  469. comment on column USER_TABLES.DEGREE is
  470. 'The number of threads per instance for scanning the table'
  471. /
  472. comment on column USER_TABLES.INSTANCES is
  473. 'The number of instances across which the table is to be scanned'
  474. /
  475. comment on column USER_TABLES.CACHE is
  476. 'Whether the table is to be cached in the buffer cache'
  477. /
  478. drop public synonym USER_TABLES
  479. /
  480. create public synonym USER_TABLES for USER_TABLES
  481. /
  482. drop public synonym TABS
  483. /
  484. create public synonym TABS for USER_TABLES
  485. /
  486. grant select on USER_TABLES to PUBLIC with grant option
  487. /
  488. create or replace view ALL_TABLES
  489.     (OWNER, TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME,
  490.      PCT_FREE, PCT_USED,
  491.      INI_TRANS, MAX_TRANS,
  492.      INITIAL_EXTENT, NEXT_EXTENT,
  493.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  494.      BACKED_UP, NUM_ROWS, BLOCKS, EMPTY_BLOCKS,
  495.      AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN,
  496.      DEGREE, INSTANCES, CACHE)
  497. as
  498. select u.name, o.name, ts.name, co.name,
  499.        t.pctfree$, t.pctused$,
  500.        t.initrans, t.maxtrans,
  501.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  502.        s.minexts, s.maxexts, s.extpct,
  503.        decode(t.modified, 0, 'Y', 1, 'N', '?'),
  504.        t.rowcnt, t.blkcnt, t.empcnt, t.avgspc, t.chncnt, t.avgrln,
  505.        lpad(decode(t.spare1, 0, '1', 1, 'DEFAULT', to_char(t.spare1)), 10),
  506.        lpad(decode(mod(t.spare2, 65536), 0, '1', 1, 'DEFAULT',
  507.        to_char(mod(t.spare2, 65536))), 10),
  508.        lpad(decode(floor(t.spare2 / 65536), 0, 'N', 1, 'Y', '?'), 5)
  509. from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o
  510. where o.owner# = u.user#
  511.   and o.obj# = t.obj#
  512.   and t.clu# = co.obj# (+)
  513.   and t.ts# = ts.ts#
  514.   and t.file# = s.file# (+)
  515.   and t.block# = s.block# (+)
  516.   and (o.owner# = userenv('SCHEMAID')
  517.        or o.obj# in
  518.             (select oa.obj#
  519.              from sys.objauth$ oa
  520.              where grantee# in ( select kzsrorol
  521.                                  from x$kzsro
  522.                                ) 
  523.             )
  524.        or /* user has system privileges */
  525.      exists (select null from v$enabledprivs
  526.              where priv_number in (-45 /* LOCK ANY TABLE */,
  527.                        -47 /* SELECT ANY TABLE */,
  528.                        -48 /* INSERT ANY TABLE */,
  529.                        -49 /* UPDATE ANY TABLE */,
  530.                        -50 /* DELETE ANY TABLE */)
  531.                  )
  532.       )
  533. /
  534. comment on table ALL_TABLES is
  535. 'Description of tables accessible to the user'
  536. /
  537. comment on column ALL_TABLES.OWNER is
  538. 'Owner of the table'
  539. /
  540. comment on column ALL_TABLES.TABLE_NAME is
  541. 'Name of the table'
  542. /
  543. comment on column ALL_TABLES.TABLESPACE_NAME is
  544. 'Name of the tablespace containing the table'
  545. /
  546. comment on column ALL_TABLES.CLUSTER_NAME is
  547. 'Name of the cluster, if any, to which the table belongs'
  548. /
  549. comment on column ALL_TABLES.PCT_FREE is
  550. 'Minimum percentage of free space in a block'
  551. /
  552. comment on column ALL_TABLES.PCT_USED is
  553. 'Minimum percentage of used space in a block'
  554. /
  555. comment on column ALL_TABLES.INI_TRANS is
  556. 'Initial number of transactions'
  557. /
  558. comment on column ALL_TABLES.MAX_TRANS is
  559. 'Maximum number of transactions'
  560. /
  561. comment on column ALL_TABLES.INITIAL_EXTENT is
  562. 'Size of the initial extent in bytes'
  563. /
  564. comment on column ALL_TABLES.NEXT_EXTENT is
  565. 'Size of secondary extents in bytes'
  566. /
  567. comment on column ALL_TABLES.MIN_EXTENTS is
  568. 'Minimum number of extents allowed in the segment'
  569. /
  570. comment on column ALL_TABLES.MAX_EXTENTS is
  571. 'Maximum number of extents allowed in the segment'
  572. /
  573. comment on column ALL_TABLES.PCT_INCREASE is
  574. 'Percentage increase in extent size'
  575. /
  576. comment on column ALL_TABLES.BACKED_UP is
  577. 'Has table been backed up since last modification?'
  578. /
  579. comment on column ALL_TABLES.NUM_ROWS is
  580. 'The number of rows in the table'
  581. /
  582. comment on column ALL_TABLES.BLOCKS is
  583. 'The number of used blocks in the table'
  584. /
  585. comment on column ALL_TABLES.EMPTY_BLOCKS is
  586. 'The number of empty (never used) blocks in the table'
  587. /
  588. comment on column ALL_TABLES.AVG_SPACE is
  589. 'The average available free space in the table'
  590. /
  591. comment on column ALL_TABLES.CHAIN_CNT is
  592. 'The number of chained rows in the table'
  593. /
  594. comment on column ALL_TABLES.AVG_ROW_LEN is
  595. 'The average row length, including row overhead'
  596. /
  597. comment on column ALL_TABLES.DEGREE is
  598. 'The number of threads per instance for scanning the table'
  599. /
  600. comment on column ALL_TABLES.INSTANCES is
  601. 'The number of instances across which the table is to be scanned'
  602. /
  603. comment on column ALL_TABLES.CACHE is
  604. 'Whether the table is to be cached in the buffer cache'
  605. /
  606. drop public synonym ALL_TABLES
  607. /
  608. create public synonym ALL_TABLES for ALL_TABLES
  609. /
  610. grant select on ALL_TABLES to PUBLIC with grant option
  611. /
  612. create or replace view DBA_TABLES
  613.     (OWNER, TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME,
  614.      PCT_FREE, PCT_USED,
  615.      INI_TRANS, MAX_TRANS,
  616.      INITIAL_EXTENT, NEXT_EXTENT,
  617.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  618.      BACKED_UP, NUM_ROWS, BLOCKS, EMPTY_BLOCKS,
  619.      AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN,
  620.      DEGREE, INSTANCES, CACHE)
  621. as
  622. select u.name, o.name, ts.name, co.name,
  623.        t.pctfree$, t.pctused$,
  624.        t.initrans, t.maxtrans,
  625.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  626.        s.minexts, s.maxexts, s.extpct,
  627.        decode(t.modified, 0, 'Y', 1, 'N', '?'),
  628.        t.rowcnt, t.blkcnt, t.empcnt, t.avgspc, t.chncnt, t.avgrln,
  629.        lpad(decode(t.spare1, 0, '1', 1, 'DEFAULT', to_char(t.spare1)), 10),
  630.        lpad(decode(mod(t.spare2, 65536), 0, '1', 1, 'DEFAULT',
  631.        to_char(mod(t.spare2, 65536))), 10),
  632.        lpad(decode(floor(t.spare2 / 65536), 0, 'N', 1, 'Y', '?'), 5)
  633. from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o
  634. where o.owner# = u.user#
  635.   and o.obj# = t.obj#
  636.   and t.clu# = co.obj# (+)
  637.   and t.ts# = ts.ts#
  638.   and t.file# = s.file# (+)
  639.   and t.block# = s.block# (+)
  640. /
  641. comment on table DBA_TABLES is
  642. 'Description of all tables in the database'
  643. /
  644. comment on column DBA_TABLES.OWNER is
  645. 'Owner of the table'
  646. /
  647. comment on column DBA_TABLES.TABLE_NAME is
  648. 'Name of the table'
  649. /
  650. comment on column DBA_TABLES.TABLESPACE_NAME is
  651. 'Name of the tablespace containing the table'
  652. /
  653. comment on column DBA_TABLES.CLUSTER_NAME is
  654. 'Name of the cluster, if any, to which the table belongs'
  655. /
  656. comment on column DBA_TABLES.PCT_FREE is
  657. 'Minimum percentage of free space in a block'
  658. /
  659. comment on column DBA_TABLES.PCT_USED is
  660. 'Minimum percentage of used space in a block'
  661. /
  662. comment on column DBA_TABLES.INI_TRANS is
  663. 'Initial number of transactions'
  664. /
  665. comment on column DBA_TABLES.MAX_TRANS is
  666. 'Maximum number of transactions'
  667. /
  668. comment on column DBA_TABLES.INITIAL_EXTENT is
  669. 'Size of the initial extent in bytes'
  670. /
  671. comment on column DBA_TABLES.NEXT_EXTENT is
  672. 'Size of secondary extents in bytes'
  673. /
  674. comment on column DBA_TABLES.MIN_EXTENTS is
  675. 'Minimum number of extents allowed in the segment'
  676. /
  677. comment on column DBA_TABLES.MAX_EXTENTS is
  678. 'Maximum number of extents allowed in the segment'
  679. /
  680. comment on column DBA_TABLES.PCT_INCREASE is
  681. 'Percentage increase in extent size'
  682. /
  683. comment on column DBA_TABLES.BACKED_UP is
  684. 'Has table been backed up since last modification?'
  685. /
  686. comment on column DBA_TABLES.NUM_ROWS is
  687. 'The number of rows in the table'
  688. /
  689. comment on column DBA_TABLES.BLOCKS is
  690. 'The number of used blocks in the table'
  691. /
  692. comment on column DBA_TABLES.EMPTY_BLOCKS is
  693. 'The number of empty (never used) blocks in the table'
  694. /
  695. comment on column DBA_TABLES.AVG_SPACE is
  696. 'The average available free space in the table'
  697. /
  698. comment on column DBA_TABLES.CHAIN_CNT is
  699. 'The number of chained rows in the table'
  700. /
  701. comment on column DBA_TABLES.AVG_ROW_LEN is
  702. 'The average row length, including row overhead'
  703. /
  704. comment on column DBA_TABLES.DEGREE is
  705. 'The number of threads per instance for scanning the table'
  706. /
  707. comment on column DBA_TABLES.INSTANCES is
  708. 'The number of instances across which the table is to be scanned'
  709. /
  710. comment on column DBA_TABLES.CACHE is
  711. 'Whether the table is to be cached in the buffer cache'
  712. /
  713. rem
  714. rem  v$option
  715. rem
  716. create or replace view v_$option as select * from v$option;
  717. drop public synonym v$option;
  718. create public synonym v$option for v_$option;
  719. grant select on v_$option to public;
  720.  
  721. Remark replace USER_SEGMENTS and DBA_SEGMENTS with versions in which 
  722. Remark INITIAL_EXTENT and NEXT_EXTENT are in units of bytes, not blocks
  723. create or replace view USER_SEGMENTS
  724.     (SEGMENT_NAME,
  725.      SEGMENT_TYPE,
  726.      TABLESPACE_NAME,
  727.      BYTES, BLOCKS, EXTENTS, 
  728.      INITIAL_EXTENT, NEXT_EXTENT, 
  729.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE, FREELISTS, FREELIST_GROUPS)
  730. as
  731. select o.name,
  732.        so.object_type,
  733.        ts.name,
  734.        s.blocks * ts.blocksize, s.blocks, s.extents, 
  735.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  736.        s.maxexts, s.extpct,
  737.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  738. from sys.obj$ o, sys.ts$ ts, sys.sys_objects so, sys.seg$ s
  739. where s.file# = so.header_file
  740.   and s.block# = so.header_block
  741.   and s.ts# = ts.ts#
  742.   and o.obj# = so.object_id
  743.   and o.owner# = userenv('SCHEMAID')
  744.   and s.type = so.segment_type_id
  745.   and o.type = so.object_type_id
  746. union all
  747. select un.name,
  748.        'ROLLBACK',
  749.        ts.name,
  750.        s.blocks * ts.blocksize, s.blocks, s.extents,
  751.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  752.        s.maxexts, s.extpct,
  753.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  754. from sys.ts$ ts, sys.undo$ un, sys.seg$ s
  755. where s.file# = un.file#
  756.   and s.block# = un.block#
  757.   and s.ts# = ts.ts#
  758.   and s.user# = userenv('SCHEMAID')
  759.   and s.type = 1
  760.   and un.status$ != 1  
  761. union all
  762. select to_char(s.file#) || '.' || to_char(s.block#),
  763.        decode(s.type, 2, 'DEFERRED ROLLBACK', 3, 'TEMPORARY',
  764.                       4, 'CACHE', 'UNDEFINED'),
  765.        ts.name,
  766.        s.blocks * ts.blocksize, s.blocks, s.extents,
  767.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  768.        s.maxexts, s.extpct,
  769.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  770. from sys.ts$ ts, sys.seg$ s
  771. where s.ts# = ts.ts#
  772.   and s.user# = userenv('SCHEMAID')
  773.   and s.type not in (1, 5, 6)
  774. /
  775. comment on table USER_SEGMENTS is
  776. 'Storage allocated for all database segments'
  777. /
  778. comment on column USER_SEGMENTS.SEGMENT_NAME is
  779. 'Name, if any, of the segment'
  780. /
  781. comment on column USER_SEGMENTS.SEGMENT_TYPE is
  782. 'Type of segment:  "TABLE", "CLUSTER", "INDEX", "ROLLBACK",
  783. "DEFERRED ROLLBACK", "TEMPORARY", or "CACHE"'
  784. /
  785. comment on column USER_SEGMENTS.TABLESPACE_NAME is
  786. 'Name of the tablespace containing the segment'
  787. /
  788. comment on column USER_SEGMENTS.BYTES is
  789. 'Size, in bytes, of the segment'
  790. /
  791. comment on column USER_SEGMENTS.BLOCKS is
  792. 'Size, in Oracle blocks, of the segment'
  793. /
  794. comment on column USER_SEGMENTS.EXTENTS is
  795. 'Number of extents allocated to the segment'
  796. /
  797. comment on column USER_SEGMENTS.INITIAL_EXTENT is
  798. 'Size, in bytes, of the initial extent of the segment'
  799. /
  800. comment on column USER_SEGMENTS.NEXT_EXTENT is
  801. 'Size, in bytes, of the next extent to be allocated to the segment' 
  802. /
  803. comment on column USER_SEGMENTS.MIN_EXTENTS is
  804. 'Minimum number of extents allowed in the segment'
  805. /
  806. comment on column USER_SEGMENTS.MAX_EXTENTS is
  807. 'Maximum number of extents allowed in the segment'
  808. /
  809. comment on column USER_SEGMENTS.PCT_INCREASE is
  810. 'Percent by which to increase the size of the next extent to be allocated'
  811. /
  812. comment on column USER_SEGMENTS.FREELISTS is
  813. 'Number of process freelists allocated to this segment'
  814. /
  815. comment on column USER_SEGMENTS.FREELIST_GROUPS is
  816. 'Number of freelist groups allocated to this segment'
  817. /
  818. drop public synonym USER_SEGMENTS
  819. /
  820. create public synonym USER_SEGMENTS for USER_SEGMENTS
  821. /
  822. grant select on USER_SEGMENTS to PUBLIC with grant option
  823. /
  824. create or replace view DBA_SEGMENTS
  825.     (OWNER, SEGMENT_NAME,
  826.      SEGMENT_TYPE,
  827.      TABLESPACE_NAME,
  828.      HEADER_FILE, HEADER_BLOCK,
  829.      BYTES, BLOCKS, EXTENTS, 
  830.      INITIAL_EXTENT, NEXT_EXTENT,
  831.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE, FREELISTS, FREELIST_GROUPS)
  832. as
  833. select u.name, o.name,
  834.        so.object_type,
  835.        ts.name,
  836.        s.file#, s.block#,
  837.        s.blocks * ts.blocksize, s.blocks, s.extents, 
  838.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  839.        s.maxexts, s.extpct,
  840.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  841. from sys.user$ u, sys.obj$ o, sys.ts$ ts, sys.sys_objects so, sys.seg$ s
  842. where s.file# = so.header_file
  843.   and s.block# = so.header_block
  844.   and s.ts# = ts.ts#
  845.   and o.obj# = so.object_id
  846.   and o.owner# = u.user#
  847.   and s.type = so.segment_type_id
  848.   and o.type = so.object_type_id
  849. union all
  850. select u.name, un.name,
  851.        'ROLLBACK', ts.name, s.file#, s.block#,
  852.        s.blocks * ts.blocksize, s.blocks, s.extents,
  853.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  854.        s.maxexts, s.extpct,
  855.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  856. from sys.user$ u, sys.ts$ ts, sys.undo$ un, sys.seg$ s
  857. where s.file# = un.file#
  858.   and s.block# = un.block#
  859.   and s.ts# = ts.ts#
  860.   and s.user# = u.user#
  861.   and s.type = 1
  862.   and un.status$ != 1
  863. union all
  864. select u.name, to_char(s.file#) || '.' || to_char(s.block#),
  865.        decode(s.type, 2, 'DEFERRED ROLLBACK', 3, 'TEMPORARY',
  866.                       4, 'CACHE', 'UNDEFINED'),
  867.        ts.name,
  868.        s.file#, s.block#,
  869.        s.blocks * ts.blocksize, s.blocks, s.extents,
  870.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize, s.minexts, 
  871.        s.maxexts, s.extpct,
  872.        decode(s.lists, 0, 1, s.lists), decode(s.groups, 0, 1, s.groups)
  873. from sys.user$ u, sys.ts$ ts, sys.seg$ s
  874. where s.ts# = ts.ts#
  875.   and s.user# = u.user#
  876.   and s.type not in (1, 5, 6)
  877. /
  878. comment on table DBA_SEGMENTS is
  879. 'Storage allocated for all database segments'
  880. /
  881. comment on column DBA_SEGMENTS.OWNER is
  882. 'Username of the segment owner'
  883. /
  884. comment on column DBA_SEGMENTS.SEGMENT_NAME is
  885. 'Name, if any, of the segment'
  886. /
  887. comment on column DBA_SEGMENTS.SEGMENT_TYPE is
  888. 'Type of segment:  "TABLE", "CLUSTER", "INDEX", "ROLLBACK",
  889. "DEFERRED ROLLBACK", "TEMPORARY", or "CACHE"'
  890. /
  891. comment on column DBA_SEGMENTS.TABLESPACE_NAME is
  892. 'Name of the tablespace containing the segment'
  893. /
  894. comment on column DBA_SEGMENTS.HEADER_FILE is
  895. 'ID of the file containing the segment header'
  896. /
  897. comment on column DBA_SEGMENTS.HEADER_BLOCK is
  898. 'ID of the block containing the segment header'
  899. /
  900. comment on column DBA_SEGMENTS.BYTES is
  901. 'Size, in bytes, of the segment'
  902. /
  903. comment on column DBA_SEGMENTS.BLOCKS is
  904. 'Size, in Oracle blocks, of the segment'
  905. /
  906. comment on column DBA_SEGMENTS.EXTENTS is
  907. 'Number of extents allocated to the segment'
  908. /
  909. comment on column DBA_SEGMENTS.INITIAL_EXTENT is
  910. 'Size, in bytes, of the initial extent of the segment'
  911. /
  912. comment on column DBA_SEGMENTS.NEXT_EXTENT is
  913. 'Size, in bytes, of the next extent to be allocated to the segment' 
  914. /
  915. comment on column DBA_SEGMENTS.MIN_EXTENTS is
  916. 'Minimum number of extents allowed in the segment'
  917. /
  918. comment on column DBA_SEGMENTS.MAX_EXTENTS is
  919. 'Maximum number of extents allowed in the segment'
  920. /
  921. comment on column DBA_SEGMENTS.PCT_INCREASE is
  922. 'Percent by which to increase the size of the next extent to be allocated'
  923. /
  924. comment on column DBA_SEGMENTS.FREELISTS is
  925. 'Number of process freelists allocated in this segment'
  926. /
  927. comment on column DBA_SEGMENTS.FREELIST_GROUPS is
  928. 'Number of freelist groups allocated in this segment'
  929. /
  930. Rem
  931. Rem expact table for Export actions
  932. Rem
  933. drop table expact$
  934. /
  935. create table expact$
  936. ( owner varchar2(30) not null,                             /* owner of table */
  937.   name  varchar2(30) not null,                              /* name of table */
  938.   func_schema varchar2(30) not null,             /* schema func is run under */
  939.   func_package  varchar2(30) not null,                       /* package name */
  940.   func_proc  varchar2(30) not null,                        /* procedure name */
  941.   code  number not null,                            /* PRETABLE OR POSTTABLE */
  942.   callorder number)
  943. /
  944. Rem
  945. Rem The index i_triggercol1 on triggercol$ changed (If you run this file
  946. Rem on a 7.1.3 or later database, the following 2 statements may fail. That
  947. Rem is not a problem.
  948. Rem
  949. create index i_triggercol on triggercol$(obj#, col#, type, position)
  950. /
  951. drop index i_triggercol1
  952. /
  953.  
  954. create or replace view v_$compatibility as
  955.   select * from v$compatibility;
  956. drop public synonym v$compatibility;
  957. create public synonym v$compatibility for v_$compatibility;
  958.  
  959. create or replace view v_$compatseg as
  960.   select * from v$compatseg;
  961. drop public synonym v$compatseg;
  962. create public synonym v$compatseg for v_$compatseg;
  963.  
  964. remark
  965. remark  FAMILY "CLUSTERS"
  966. remark  CREATE CLUSTER parameters.
  967. remark  This family has no "ALL" member.
  968. remark
  969. create or replace view USER_CLUSTERS
  970.     (CLUSTER_NAME, TABLESPACE_NAME,
  971.      PCT_FREE, PCT_USED, KEY_SIZE,
  972.      INI_TRANS, MAX_TRANS,
  973.      INITIAL_EXTENT, NEXT_EXTENT,
  974.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  975.      AVG_BLOCKS_PER_KEY,
  976.      CLUSTER_TYPE, FUNCTION, HASHKEYS, PARALLEL, CACHE)
  977. as select o.name, ts.name,
  978.           c.pctfree$, c.pctused$, c.size$,c.initrans,c.maxtrans,
  979.           s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  980.           s.minexts, s.maxexts, s.extpct,
  981.           c.spare4, decode(c.hashkeys, 0, 'INDEX', 'HASH'),
  982.           decode(c.hashkeys, 0, NULL,
  983.                  decode(c.func, 0, 'COLUMN', 1, 'DEFAULT', NULL)),
  984.           c.hashkeys,
  985.           decode(c.spare5, 0, 'N', 1, 'Y', to_char(c.spare5, '99999')),
  986.           decode(c.spare6, 0, 'N', 1, 'Y',
  987.                  'PARTITIONS '||ltrim(to_char(c.spare6, '99999')))
  988. from sys.ts$ ts, sys.seg$ s, sys.clu$ c, sys.obj$ o
  989. where o.owner# = userenv('SCHEMAID')
  990.   and o.obj# = c.obj#
  991.   and c.ts# = ts.ts# 
  992.   and c.ts# = s.ts#
  993.   and c.file# = s.file#
  994.   and c.block# = s.block#
  995. /
  996. comment on table USER_CLUSTERS is
  997. 'Descriptions of user''s own clusters'
  998. /
  999. comment on column USER_CLUSTERS.CLUSTER_NAME is
  1000. 'Name of the cluster'
  1001. /
  1002. comment on column USER_CLUSTERS.TABLESPACE_NAME is
  1003. 'Name of the tablespace containing the cluster'
  1004. /
  1005. comment on column USER_CLUSTERS.PCT_FREE is
  1006. 'Minimum percentage of free space in a block'
  1007. /
  1008. comment on column USER_CLUSTERS.PCT_USED is
  1009. 'Minimum percentage of used space in a block'
  1010. /
  1011. comment on column USER_CLUSTERS.KEY_SIZE is
  1012. 'Estimated size of cluster key plus associated rows'
  1013. /
  1014. comment on column USER_CLUSTERS.INI_TRANS is
  1015. 'Initial number of transactions'
  1016. /
  1017. comment on column USER_CLUSTERS.MAX_TRANS is
  1018. 'Maximum number of transactions'
  1019. /
  1020. comment on column USER_CLUSTERS.INITIAL_EXTENT is
  1021. 'Size of the initial extent in bytes'
  1022. /
  1023. comment on column USER_CLUSTERS.NEXT_EXTENT is
  1024. 'Size of secondary extents in bytes'
  1025. /
  1026. comment on column USER_CLUSTERS.MIN_EXTENTS is
  1027. 'Minimum number of extents allowed in the segment'
  1028. /
  1029. comment on column USER_CLUSTERS.MAX_EXTENTS is
  1030. 'Maximum number of extents allowed in the segment'
  1031. /
  1032. comment on column USER_CLUSTERS.PCT_INCREASE is
  1033. 'Percentage increase in extent size'
  1034. /
  1035. comment on column USER_CLUSTERS.AVG_BLOCKS_PER_KEY is
  1036. 'Average number of blocks containing rows with a given cluster key'
  1037. /
  1038. comment on column USER_CLUSTERS.CLUSTER_TYPE is
  1039. 'Type of cluster: b-tree index or hash'
  1040. /
  1041. comment on column USER_CLUSTERS.FUNCTION is
  1042. 'If a hash cluster, the hash function'
  1043. /
  1044. comment on column USER_CLUSTERS.HASHKEYS is
  1045. 'If a hash cluster, the number of hash keys (hash buckets)'
  1046. /
  1047. comment on column USER_CLUSTERS.PARALLEL is
  1048. 'The degree of parallelism assigned to the cluster'
  1049. /
  1050. comment on column USER_CLUSTERS.CACHE is
  1051. 'The caching parameter associated with the cluster'
  1052. /
  1053. drop public synonym USER_CLUSTERS
  1054. /
  1055. create public synonym USER_CLUSTERS for USER_CLUSTERS
  1056. /
  1057. drop public synonym CLU
  1058. /
  1059. create public synonym CLU for USER_CLUSTERS
  1060. /
  1061. grant select on USER_CLUSTERS to PUBLIC with grant option
  1062. /
  1063. create or replace view DBA_CLUSTERS
  1064.     (OWNER, CLUSTER_NAME, TABLESPACE_NAME,
  1065.      PCT_FREE, PCT_USED, KEY_SIZE,
  1066.      INI_TRANS, MAX_TRANS,
  1067.      INITIAL_EXTENT, NEXT_EXTENT,
  1068.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  1069.      AVG_BLOCKS_PER_KEY,
  1070.      CLUSTER_TYPE, FUNCTION, HASHKEYS, PARALLEL, CACHE)
  1071. as select u.name, o.name, ts.name,
  1072.           c.pctfree$, c.pctused$, c.size$,c.initrans,c.maxtrans,
  1073.           s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  1074.           s.minexts, s.maxexts, s.extpct,
  1075.           c.spare4, decode(c.hashkeys, 0, 'INDEX', 'HASH'),
  1076.           decode(c.hashkeys, 0, NULL,
  1077.                  decode(c.func, 0, 'COLUMN', 1, 'DEFAULT', NULL)),
  1078.           c.hashkeys,
  1079.           decode(c.spare5, 0, 'N', 1, 'Y', to_char(c.spare5, '99999')),
  1080.           decode(c.spare6, 0, 'N', 1, 'Y',
  1081.                  'PARTITIONS '||ltrim(to_char(c.spare6, '99999')))
  1082. from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.clu$ c, sys.obj$ o
  1083. where o.owner# = u.user#
  1084.   and o.obj# = c.obj#
  1085.   and c.ts# = ts.ts#
  1086.   and c.ts# = s.ts#
  1087.   and c.file# = s.file#
  1088.   and c.block# = s.block#
  1089. /
  1090. comment on table DBA_CLUSTERS is
  1091. 'Description of all clusters in the database'
  1092. /
  1093. comment on column DBA_CLUSTERS.OWNER is
  1094. 'Owner of the cluster'
  1095. /
  1096. comment on column DBA_CLUSTERS.CLUSTER_NAME is
  1097. 'Name of the cluster'
  1098. /
  1099. comment on column DBA_CLUSTERS.TABLESPACE_NAME is
  1100. 'Name of the tablespace containing the cluster'
  1101. /
  1102. comment on column DBA_CLUSTERS.PCT_FREE is
  1103. 'Minimum percentage of free space in a block'
  1104. /
  1105. comment on column DBA_CLUSTERS.PCT_USED is
  1106. 'Minimum percentage of used space in a block'
  1107. /
  1108. comment on column DBA_CLUSTERS.KEY_SIZE is
  1109. 'Estimated size of cluster key plus associated rows'
  1110. /
  1111. comment on column DBA_CLUSTERS.INI_TRANS is
  1112. 'Initial number of transactions'
  1113. /
  1114. comment on column DBA_CLUSTERS.MAX_TRANS is
  1115. 'Maximum number of transactions'
  1116. /
  1117. comment on column DBA_CLUSTERS.INITIAL_EXTENT is
  1118. 'Size of the initial extent in bytes'
  1119. /
  1120. comment on column DBA_CLUSTERS.NEXT_EXTENT is
  1121. 'Size of secondary extents in bytes'
  1122. /
  1123. comment on column DBA_CLUSTERS.MIN_EXTENTS is
  1124. 'Minimum number of extents allowed in the segment'
  1125. /
  1126. comment on column DBA_CLUSTERS.MAX_EXTENTS is
  1127. 'Maximum number of extents allowed in the segment'
  1128. /
  1129. comment on column DBA_CLUSTERS.PCT_INCREASE is
  1130. 'Percentage increase in extent size'
  1131. /
  1132. comment on column DBA_CLUSTERS.AVG_BLOCKS_PER_KEY is
  1133. 'Average number of blocks containing rows with a given cluster key'
  1134. /
  1135. comment on column DBA_CLUSTERS.CLUSTER_TYPE is
  1136. 'Type of cluster: b-tree index or hash'
  1137. /
  1138. comment on column DBA_CLUSTERS.FUNCTION is
  1139. 'If a hash cluster, the hash function'
  1140. /
  1141. comment on column DBA_CLUSTERS.HASHKEYS is
  1142. 'If a hash cluster, the number of hash keys (hash buckets)'
  1143. /
  1144. comment on column DBA_CLUSTERS.PARALLEL is
  1145. 'The degree of parallelism assigned to the cluster'
  1146. /
  1147. comment on column DBA_CLUSTERS.CACHE is
  1148. 'The caching parameter associated with the cluster'
  1149. /
  1150. remark
  1151. remark  FAMILY "TABLES"
  1152. remark  CREATE TABLE parameters.
  1153. remark
  1154. create or replace view USER_TABLES
  1155.     (TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME,
  1156.      PCT_FREE, PCT_USED,
  1157.      INI_TRANS, MAX_TRANS,
  1158.      INITIAL_EXTENT, NEXT_EXTENT,
  1159.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  1160.      BACKED_UP, NUM_ROWS, BLOCKS, EMPTY_BLOCKS,
  1161.      AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN, PARALLEL, CACHE)
  1162. as
  1163. select o.name, ts.name, co.name,
  1164.        t.pctfree$, t.pctused$,
  1165.        t.initrans, t.maxtrans,
  1166.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  1167.        s.minexts, s.maxexts, s.extpct,
  1168.        decode(t.modified, 0, 'Y', 1, 'N', '?'),
  1169.        t.rowcnt, t.blkcnt, t.empcnt, t.avgspc, t.chncnt, t.avgrln,
  1170.        decode(t.spare1, 0, 'N', 1, 'Y', to_char(t.spare1, '99999')),
  1171.        decode(t.spare2, 0, 'N', 1, 'Y',
  1172.               'PARTITIONS '||ltrim(to_char(t.spare2, '99999')))
  1173. from sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o
  1174. where o.owner# = userenv('SCHEMAID')
  1175.   and o.obj# = t.obj#
  1176.   and t.clu# = co.obj# (+)
  1177.   and t.ts# = ts.ts#
  1178.   and t.file# = s.file# (+)
  1179.   and t.block# = s.block# (+)
  1180. /
  1181. comment on table USER_TABLES is
  1182. 'Description of the user''s own tables'
  1183. /
  1184. comment on column USER_TABLES.TABLE_NAME is
  1185. 'Name of the table'
  1186. /
  1187. comment on column USER_TABLES.TABLESPACE_NAME is
  1188. 'Name of the tablespace containing the table'
  1189. /
  1190. comment on column USER_TABLES.CLUSTER_NAME is
  1191. 'Name of the cluster, if any, to which the table belongs'
  1192. /
  1193. comment on column USER_TABLES.PCT_FREE is
  1194. 'Minimum percentage of free space in a block'
  1195. /
  1196. comment on column USER_TABLES.PCT_USED is
  1197. 'Minimum percentage of used space in a block'
  1198. /
  1199. comment on column USER_TABLES.INI_TRANS is
  1200. 'Initial number of transactions'
  1201. /
  1202. comment on column USER_TABLES.MAX_TRANS is
  1203. 'Maximum number of transactions'
  1204. /
  1205. comment on column USER_TABLES.INITIAL_EXTENT is
  1206. 'Size of the initial extent in bytes'
  1207. /
  1208. comment on column USER_TABLES.NEXT_EXTENT is
  1209. 'Size of secondary extents in bytes'
  1210. /
  1211. comment on column USER_TABLES.MIN_EXTENTS is
  1212. 'Minimum number of extents allowed in the segment'
  1213. /
  1214. comment on column USER_TABLES.MAX_EXTENTS is
  1215. 'Maximum number of extents allowed in the segment'
  1216. /
  1217. comment on column USER_TABLES.PCT_INCREASE is
  1218. 'Percentage increase in extent size'
  1219. /
  1220. comment on column USER_TABLES.BACKED_UP is
  1221. 'Has table been backed up since last modification?'
  1222. /
  1223. comment on column USER_TABLES.NUM_ROWS is
  1224. 'The number of rows in the table'
  1225. /
  1226. comment on column USER_TABLES.BLOCKS is
  1227. 'The number of used blocks in the table'
  1228. /
  1229. comment on column USER_TABLES.EMPTY_BLOCKS is
  1230. 'The number of empty (never used) blocks in the table'
  1231. /
  1232. comment on column USER_TABLES.AVG_SPACE is
  1233. 'The average available free space in the table'
  1234. /
  1235. comment on column USER_TABLES.CHAIN_CNT is
  1236. 'The number of chained rows in the table'
  1237. /
  1238. comment on column USER_TABLES.AVG_ROW_LEN is
  1239. 'The average row length, including row overhead'
  1240. /
  1241. comment on column USER_TABLES.PARALLEL is
  1242. 'The degree of parallelism assigned to the table'
  1243. /
  1244. comment on column USER_TABLES.CACHE is
  1245. 'The caching parameter associated with the table'
  1246. /
  1247. drop public synonym USER_TABLES
  1248. /
  1249. create public synonym USER_TABLES for USER_TABLES
  1250. /
  1251. drop public synonym TABS
  1252. /
  1253. create public synonym TABS for USER_TABLES
  1254. /
  1255. grant select on USER_TABLES to PUBLIC with grant option
  1256. /
  1257. create or replace view ALL_TABLES
  1258.     (OWNER, TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME,
  1259.      PCT_FREE, PCT_USED,
  1260.      INI_TRANS, MAX_TRANS,
  1261.      INITIAL_EXTENT, NEXT_EXTENT,
  1262.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  1263.      BACKED_UP, NUM_ROWS, BLOCKS, EMPTY_BLOCKS,
  1264.      AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN, PARALLEL, CACHE)
  1265. as
  1266. select u.name, o.name, ts.name, co.name,
  1267.        t.pctfree$, t.pctused$,
  1268.        t.initrans, t.maxtrans,
  1269.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  1270.        s.minexts, s.maxexts, s.extpct,
  1271.        decode(t.modified, 0, 'Y', 1, 'N', '?'),
  1272.        t.rowcnt, t.blkcnt, t.empcnt, t.avgspc, t.chncnt, t.avgrln,
  1273.        decode(t.spare1, 0, 'N', 1, 'Y', to_char(t.spare1, '99999')),
  1274.        decode(t.spare2, 0, 'N', 1, 'Y',
  1275.               'PARTITIONS '||ltrim(to_char(t.spare2, '99999')))
  1276. from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o
  1277. where o.owner# = u.user#
  1278.   and o.obj# = t.obj#
  1279.   and t.clu# = co.obj# (+)
  1280.   and t.ts# = ts.ts#
  1281.   and t.file# = s.file# (+)
  1282.   and t.block# = s.block# (+)
  1283.   and (o.owner# = userenv('SCHEMAID')
  1284.        or o.obj# in
  1285.             (select oa.obj#
  1286.              from sys.objauth$ oa
  1287.              where grantee# in ( select kzsrorol
  1288.                                  from x$kzsro
  1289.                                ) 
  1290.             )
  1291.        or /* user has system privileges */
  1292.      exists (select null from v$enabledprivs
  1293.              where priv_number in (-45 /* LOCK ANY TABLE */,
  1294.                        -47 /* SELECT ANY TABLE */,
  1295.                        -48 /* INSERT ANY TABLE */,
  1296.                        -49 /* UPDATE ANY TABLE */,
  1297.                        -50 /* DELETE ANY TABLE */)
  1298.                  )
  1299.       )
  1300. /
  1301. comment on table ALL_TABLES is
  1302. 'Description of tables accessible to the user'
  1303. /
  1304. comment on column ALL_TABLES.OWNER is
  1305. 'Owner of the table'
  1306. /
  1307. comment on column ALL_TABLES.TABLE_NAME is
  1308. 'Name of the table'
  1309. /
  1310. comment on column ALL_TABLES.TABLESPACE_NAME is
  1311. 'Name of the tablespace containing the table'
  1312. /
  1313. comment on column ALL_TABLES.CLUSTER_NAME is
  1314. 'Name of the cluster, if any, to which the table belongs'
  1315. /
  1316. comment on column ALL_TABLES.PCT_FREE is
  1317. 'Minimum percentage of free space in a block'
  1318. /
  1319. comment on column ALL_TABLES.PCT_USED is
  1320. 'Minimum percentage of used space in a block'
  1321. /
  1322. comment on column ALL_TABLES.INI_TRANS is
  1323. 'Initial number of transactions'
  1324. /
  1325. comment on column ALL_TABLES.MAX_TRANS is
  1326. 'Maximum number of transactions'
  1327. /
  1328. comment on column ALL_TABLES.INITIAL_EXTENT is
  1329. 'Size of the initial extent in bytes'
  1330. /
  1331. comment on column ALL_TABLES.NEXT_EXTENT is
  1332. 'Size of secondary extents in bytes'
  1333. /
  1334. comment on column ALL_TABLES.MIN_EXTENTS is
  1335. 'Minimum number of extents allowed in the segment'
  1336. /
  1337. comment on column ALL_TABLES.MAX_EXTENTS is
  1338. 'Maximum number of extents allowed in the segment'
  1339. /
  1340. comment on column ALL_TABLES.PCT_INCREASE is
  1341. 'Percentage increase in extent size'
  1342. /
  1343. comment on column ALL_TABLES.BACKED_UP is
  1344. 'Has table been backed up since last modification?'
  1345. /
  1346. comment on column ALL_TABLES.NUM_ROWS is
  1347. 'The number of rows in the table'
  1348. /
  1349. comment on column ALL_TABLES.BLOCKS is
  1350. 'The number of used blocks in the table'
  1351. /
  1352. comment on column ALL_TABLES.EMPTY_BLOCKS is
  1353. 'The number of empty (never used) blocks in the table'
  1354. /
  1355. comment on column ALL_TABLES.AVG_SPACE is
  1356. 'The average available free space in the table'
  1357. /
  1358. comment on column ALL_TABLES.CHAIN_CNT is
  1359. 'The number of chained rows in the table'
  1360. /
  1361. comment on column ALL_TABLES.AVG_ROW_LEN is
  1362. 'The average row length, including row overhead'
  1363. /
  1364. comment on column ALL_TABLES.PARALLEL is
  1365. 'The degree of parallelism assigned to the table'
  1366. /
  1367. comment on column ALL_TABLES.CACHE is
  1368. 'The caching parameter associated with the table'
  1369. /
  1370. drop public synonym ALL_TABLES
  1371. /
  1372. create public synonym ALL_TABLES for ALL_TABLES
  1373. /
  1374. grant select on ALL_TABLES to PUBLIC with grant option
  1375. /
  1376. create or replace view DBA_TABLES
  1377.     (OWNER, TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME,
  1378.      PCT_FREE, PCT_USED,
  1379.      INI_TRANS, MAX_TRANS,
  1380.      INITIAL_EXTENT, NEXT_EXTENT,
  1381.      MIN_EXTENTS, MAX_EXTENTS, PCT_INCREASE,
  1382.      BACKED_UP, NUM_ROWS, BLOCKS, EMPTY_BLOCKS,
  1383.      AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN, PARALLEL, CACHE)
  1384. as
  1385. select u.name, o.name, ts.name, co.name,
  1386.        t.pctfree$, t.pctused$,
  1387.        t.initrans, t.maxtrans,
  1388.        s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
  1389.        s.minexts, s.maxexts, s.extpct,
  1390.        decode(t.modified, 0, 'Y', 1, 'N', '?'),
  1391.        t.rowcnt, t.blkcnt, t.empcnt, t.avgspc, t.chncnt, t.avgrln,
  1392.        decode(t.spare1, 0, 'N', 1, 'Y', to_char(t.spare1, '99999')),
  1393.        decode(t.spare2, 0, 'N', 1, 'Y',
  1394.               'PARTITIONS '||ltrim(to_char(t.spare2, '99999')))
  1395. from sys.user$ u, sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o
  1396. where o.owner# = u.user#
  1397.   and o.obj# = t.obj#
  1398.   and t.clu# = co.obj# (+)
  1399.   and t.ts# = ts.ts#
  1400.   and t.file# = s.file# (+)
  1401.   and t.block# = s.block# (+)
  1402. /
  1403. comment on table DBA_TABLES is
  1404. 'Description of all tables in the database'
  1405. /
  1406. comment on column DBA_TABLES.OWNER is
  1407. 'Owner of the table'
  1408. /
  1409. comment on column DBA_TABLES.TABLE_NAME is
  1410. 'Name of the table'
  1411. /
  1412. comment on column DBA_TABLES.TABLESPACE_NAME is
  1413. 'Name of the tablespace containing the table'
  1414. /
  1415. comment on column DBA_TABLES.CLUSTER_NAME is
  1416. 'Name of the cluster, if any, to which the table belongs'
  1417. /
  1418. comment on column DBA_TABLES.PCT_FREE is
  1419. 'Minimum percentage of free space in a block'
  1420. /
  1421. comment on column DBA_TABLES.PCT_USED is
  1422. 'Minimum percentage of used space in a block'
  1423. /
  1424. comment on column DBA_TABLES.INI_TRANS is
  1425. 'Initial number of transactions'
  1426. /
  1427. comment on column DBA_TABLES.MAX_TRANS is
  1428. 'Maximum number of transactions'
  1429. /
  1430. comment on column DBA_TABLES.INITIAL_EXTENT is
  1431. 'Size of the initial extent in bytes'
  1432. /
  1433. comment on column DBA_TABLES.NEXT_EXTENT is
  1434. 'Size of secondary extents in bytes'
  1435. /
  1436. comment on column DBA_TABLES.MIN_EXTENTS is
  1437. 'Minimum number of extents allowed in the segment'
  1438. /
  1439. comment on column DBA_TABLES.MAX_EXTENTS is
  1440. 'Maximum number of extents allowed in the segment'
  1441. /
  1442. comment on column DBA_TABLES.PCT_INCREASE is
  1443. 'Percentage increase in extent size'
  1444. /
  1445. comment on column DBA_TABLES.BACKED_UP is
  1446. 'Has table been backed up since last modification?'
  1447. /
  1448. comment on column DBA_TABLES.NUM_ROWS is
  1449. 'The number of rows in the table'
  1450. /
  1451. comment on column DBA_TABLES.BLOCKS is
  1452. 'The number of used blocks in the table'
  1453. /
  1454. comment on column DBA_TABLES.EMPTY_BLOCKS is
  1455. 'The number of empty (never used) blocks in the table'
  1456. /
  1457. comment on column DBA_TABLES.AVG_SPACE is
  1458. 'The average available free space in the table'
  1459. /
  1460. comment on column DBA_TABLES.CHAIN_CNT is
  1461. 'The number of chained rows in the table'
  1462. /
  1463. comment on column DBA_TABLES.AVG_ROW_LEN is
  1464. 'The average row length, including row overhead'
  1465. /
  1466. comment on column DBA_TABLES.PARALLEL is
  1467. 'The degree of parallelism assigned to the table'
  1468. /
  1469. comment on column DBA_TABLES.CACHE is
  1470. 'The caching parameter associated with the table'
  1471. /
  1472.  
  1473. create or replace view v_$option as select * from v$option;
  1474. drop public synonym v$option;
  1475. create public synonym v$option for v_$option;
  1476. grant select on v_$option to public;
  1477.  
  1478. Rem
  1479. Rem Add versioning support
  1480. Rem
  1481. insert into props$ 
  1482. values('EXPORT_VIEWS_VERSION', '1', 'Export views revision #')
  1483. /
  1484.